home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000036_icon-group-sender _Wed Apr 28 07:56:23 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 28 Apr 1993 07:46:17 MST
  2. Date: 28 Apr 1993 07:56:23 -0600 (CST)
  3. From: Chris Tenaglia - 257-8765 <TENAGLIA@mis.mcw.edu>
  4. Subject: Re: Help!
  5. To: icon-group@cs.arizona.edu
  6. Message-Id: <01GXJCRBTCHU8WW7RY@mis.mcw.edu>
  7. Organization: Medical College of Wisconsin (Milwaukee, WI)
  8. X-Vms-To: in%"icon-group@cs.arizona.edu"
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  11. Content-Transfer-Encoding: 7BIT
  12. Status: R
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14.  
  15.  
  16. On Passing several variables In and several Out:
  17.  
  18. Structures and globals are the methods I use. Structures are better if
  19. you  have  this as a widespread problem. Globals are useful in smaller
  20. cases. I use globals a lot when converting a BASIC program into ICON.
  21.  
  22. ----------------------------------------------------------------------
  23.  
  24. Method 1 : Use a structure
  25.  
  26.           stuff := obtain(a,b,c)
  27. ...
  28. # Using a List                        # Using a table
  29. procedure obtain(a,b,c)     or        procedure obtain(a,b,c)
  30.   return [x,y,z]                        result := table("")
  31.   end                                   result["x"] := 5*1.4
  32.                                         result["y"] := 22/7
  33.                                         result["z"] := ?25
  34.                                         return result
  35.                                         end
  36. ------------------------------------------------------------------------------
  37. Method 2. Use globals
  38.  
  39. global x,y,z
  40. procedure main()
  41. ...
  42.    obtain(a,b,c)
  43. end
  44.  
  45. procedure obtain(a,b,c)
  46.    x := 5*1.3
  47.    y := 22/7
  48.    z := ?25
  49.    end
  50. ---------------------------------------------------------------------
  51.  
  52. Chris Tenaglia (System Manager) |  "The past explained,
  53. Medical College of Wisconsin    |   the future fortold, 
  54. 8701 W. Watertown Plank Rd.     |   the present largely appologized for."
  55. Milwaukee, WI 53226             |   Organon to The Doctor
  56. (414)257-8765                   |     
  57. tenaglia@mis.mcw.edu
  58.